<?php 
require_once $_SERVER["DOCUMENT_ROOT"]."/inc/core/env.inc.php";

$return["success"] = false; 
$return["html"] = null;
$return["error"] = null;

if ($_USER->asPermission('mod_page')){
	$return["success"] = true;
	
	$_PAGE = new Page(null, $_POST['idPage']);
	
	$content = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-rows.tag.html');
	$row = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-row.tag.html');
	$col = file_get_contents($_SITE['path']['dir']['blocks']['containers']['admin'].'/admin-col.tag.html');
	
	$headPage = $_PAGE->get("head");
	
	$inputTextTitle = "Meta title: ".HtmlTags::createInput("text", "title", null, $headPage["title"]);
	$row1 = str_replace($_TAGS["share-content-col"], $inputTextTitle, $col);
	
	$inputTextTitle = "Meta author: ".HtmlTags::createInput("text", "author", null, $headPage["author"]);
	$row1 .= str_replace($_TAGS["share-content-col"], $inputTextTitle, $col);
	
	$inputTextTitle = "Meta keywords: ".HtmlTags::createInput("text", "keywords", null, $headPage["keywords"]);
	$row1 .= str_replace($_TAGS["share-content-col"], $inputTextTitle, $col);
	
	$textarea = "Meta description: ".htmlTags::createTextarea("desc", null, $headPage["description"]);
	$row2 =  str_replace($_TAGS["share-content-col"], $textarea, $col);
	
	$row1 = str_replace($_TAGS['share-content-columns'], $row1, $row);
	$row2 = str_replace($_TAGS['share-content-columns'], $row2, $row);
	
	$rows  = str_replace($_TAGS['admin-row-class'], 'li-meta-tag', $row1);
	$rows .= str_replace($_TAGS['admin-row-class'], 'li-meta-tag', $row2);
	$content = str_replace($_TAGS['admin-rows'], $rows, $content);
	
	$return['html'] = $_ADMIN::createWindow("Set meta tag", $content, "page");
}

echo '('.json_encode($return).')';
?>